set(TARGET_NAME kiran-cpanel-demo)

find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Widgets X11Extras Svg Xml LinguistTools)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(GSETTINGS_QT REQUIRED gsettings-qt)
pkg_search_module(KLOG_QT5 REQUIRED klog-qt5)
pkg_search_module(KIRANWIDGETS REQUIRED kiranwidgets-qt5)

file(GLOB_RECURSE DEMO_SRC "src/*.cpp" "src/*.h" "src/*.ui")
file(GLOB DEMO_TS_FILES "translations/*.ts")

qt5_create_translation(DEMO_QM_FILES ${CMAKE_SOURCE_DIR} ${DEMO_TS_FILES})
add_library(${TARGET_NAME} SHARED
        ${DEMO_SRC}
        ${DEMO_QM_FILES})

target_include_directories(${TARGET_NAME} PRIVATE
        ${CMAKE_BINARY_DIR}
        ${CMAKE_SOURCE_DIR}/include
        ${CMAKE_CURRENT_SOURCE_DIR}/subitem
        ${GLIB_INCLUDE_DIRS}
        ${GSETTINGS_QT_INCLUDE_DIRS}
        ${KIRAN_CONTROL_PANEL_PKG_INCLUDE_DIRS}
        ${KIRANWIDGETS_INCLUDE_DIRS}
        ${KLOG_QT5_INCLUDE_DIRS})

target_link_libraries(${TARGET_NAME}
        Qt5::Core
        Qt5::Gui
        Qt5::Svg
        Qt5::Widgets
        Qt5::X11Extras
        Qt5::Xml
        X11
        ${GLIB_LIBRARIES}
        ${GSETTINGS_QT_LIBRARIES}
        ${KIRANWIDGETS_LIBRARIES}
        ${KLOG_QT5_LIBRARIES})

set(PLUGIN_ICONS_DIR ${INSTALL_DATADIR}/icons/hicolor/scalable/apps )
install(TARGETS ${TARGET_NAME} DESTINATION ${PLUGIN_LIBS_DIR}/)

configure_file(data/kiran-cpanel-demo.desktop.in ${CMAKE_BINARY_DIR}/kiran-cpanel-demo.desktop @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/kiran-cpanel-demo.desktop DESTINATION ${PLUGIN_DESKTOP_DIR}/ )
install(FILES ${DEMO_QM_FILES} DESTINATION ${TRANSLATION_DIR} )
set(INSTALL_ICONS
        "data/kcp-demo-subitem-1.svg"
        "data/kcp-demo-subitem-2.svg"
        "data/kcp-demo.svg")
install(FILES ${INSTALL_ICONS} DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/)